import pymysql

class Db():
    def __init__(self):
        self.coon = pymysql.connect(
            host='127.0.0.1',
            user='root',
            password='root',
            db='p8kaoshi',
            charset='utf8',
            cursorclass=pymysql.cursors.DictCursor
        )

        self.cursor = self.coon.cursor()

    def insert(self,sql):
        self.cursor.execute(sql)
        self.coon.commit()

    def find_one(self,sql):
        self.cursor.execute(sql)
        res = self.cursor.fetchone()
        return res

    def find_all(self,sql):
        self.cursor.execute(sql)
        res = self.cursor.fetchall()
        return res

db = Db()
# db.insert("insert into ceshi values(0,'asdasda')")

# sql = "select * from ceshi"
# res = db.find_all(sql)
# print(res)